$(document).ready(function(){
	$("#nmUsuario").autocomplete({
		source: '?c=CUsuario_buscarUsuarios&tipoResposta=json&ajax=true',
		dataType: 'json',
		select: function(event, ui) {
			$("#idUsuario").val(ui.item.value);
			$("#nmUsuario").val(ui.item.label);
			$("#nmUsuario").attr('disabled','disabled');
			$("#btLimparUsuario").css('display','inline-block');
			return false;
		}
	});
	$("#btLimparUsuario").click(function(){
		$("#nmUsuario").removeAttr('disabled');
		$("#nmUsuario").val('');
		$("#idUsuario").val('');
		$(this).css('display','none');
	});

	$(".data").datepicker('destroy');
	var dates = $(".data").datepicker({
		changeMonth: true,
		changeYear: true,
		//showButtonPanel: true,
		showAnim: 'slideDown',
		onSelect: function(selectedDate) {
			var option = this.id == 'dtNascimentoInicio' ? 'minDate' : 'maxDate',
				instance = $(this).data('datepicker');
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates.not(this).datepicker('option', option,date);
		}
	});
	
	/*var dates = $("#dtNascimentoInicio, #dtNascimentoFim").datepicker({
		defaultDate: "+1w",
		changeMonth: true,
		numberOfMonths: 3,
		onSelect: function( selectedDate ) {
			var option = this.id == "from" ? "minDate" : "maxDate",
				instance = $( this ).data( "datepicker" );
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates.not( this ).datepicker( "option", option, date );
		}
	});*/

	//$("#dtNascimento").datepicker('option', 'changeYear', true);

});